package com.wqr.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class RedisController {
    @Autowired
    RedisUtils redisUtils;

    public static final String CACHE_KEY_USER="user:";

    @RequestMapping("/setString")
    @ResponseBody
    public String setString() {
        Coffee coffee = new Coffee();
        coffee.setId("1");
        coffee.setName("xc");
        redisUtils.set(CACHE_KEY_USER+coffee.getId(),coffee);
        Object object = redisUtils.get(CACHE_KEY_USER + coffee.getId());
        System.out.println((Coffee)object);
        return "done";
    }
}
